package com.yangwp.java.spider.weibo.src;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import com.yangwp.java.spider.weibo.model.Image;
import com.yangwp.java.spider.weibo.service.ImageService;

/**
 * @author 11070538
 */
@Component
public class Entry {

    @Autowired
    private ImageService imageService;

    public void main(ApplicationContext ac){

        File file = new File("D:/我的文档/11070538/Desktop/TT截图未命名.cg");
        try {
            InputStream inputStream = new FileInputStream(file);
            int size = inputStream.available();
            System.out.println(size);
            byte[] img = new byte[size];
            int readSize = inputStream.read(img);
            System.out.println(readSize);

            Image image = new Image();
            image.setImg(img);

            imageService.insert(image);
        } catch (Exception e) {
            e.printStackTrace();
        }

        String sub = "_2A253GVtXDeThGeNG6VoQ8S3LzD-IHXVUb8ufrDV8PUNbmtAKLVfnkW9NS35_lX4kYIBLAMAFmf_a12BahYeXJ52O";
        WeiboUserInfo weiboUserInfo = (WeiboUserInfo) ac.getBean("WeiboUserInfo");
        weiboUserInfo.weibo(sub);
    }
}
